package com.cntcdt.api.resources.base;

import org.apache.commons.lang.ObjectUtils;
import org.restlet.representation.Representation;
import org.restlet.resource.ResourceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.cntcdt.api.common.ErrorCode2;
import com.cntcdt.api.common.ErrorRepresentation;

public abstract class OAuthResource extends BaseResource {

    private static final Logger logger = LoggerFactory
	    .getLogger(OAuthResource.class);
    protected String accessToken; // 用户授权码
    protected Representation representation; // 错误信息，null表示没有错误
    //protected UserModel userModel; // 登录用户
   // protected UserService userService = RemoteServiceFactory.getService(UserService.class);
    
    protected int loginUid;
    
    public void doInit() throws ResourceException 
    {
		super.doInit();
		//屏蔽验证
		if (paramsMap.get("access_token") == null|| String.valueOf(paramsMap.get("access_token")).equals("")) {
		    logger.error("can't find user use access_token    new user");
		    representation = new ErrorRepresentation(ErrorCode2.ACCESS_TOKEN_ERROR, mediaType).getRepresentation();
		}else{
			accessToken = ObjectUtils.toString(paramsMap.get("access_token"), "");
		}
    }
}
